package com.zxl.springcloud.service;

import com.zxl.springcloud.entity.Student;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 *使用 feign来实现负载均衡的调用服务,可以通过替换ribbon的默认算法来修改负载方案
 */
// value填写服务提供者的 application name
@FeignClient(value = "student-provider",fallbackFactory = StudentServiceFallbackFactory.class)
@Component
public interface StudentService {

    @GetMapping("/student/findAll")
    List<Student> findAll();

    /**
     *
     *  使用 feign , server层的方法上。 @RequestMapping， method必须填写
     * @return
     */
//    @RequestMapping(value = "/student/get/{id}",method = RequestMethod.GET)
    @GetMapping("/student/get/{id}")
    Student get(@PathVariable("id") Long id);

    @PostMapping("/student/add")
    boolean add(Student student);
}
